package com.example.fbsmobile;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

public class BookingDetailsActivity extends Activity {
	String check;
	String status;
	String id;
	Class back;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_booking_betails);
		Intent intent =getIntent();
		String data=intent.getDataString();
		Bundle extras = getIntent().getExtras();
		Booking bk;
		
		if ( extras == null ) return;
		
		bk = (Booking)extras.get("booking");
			
		id = bk.get("id");
		String facility = bk.get("facility");
		String startDate = bk.get("startDate");
		String endDate = bk.get("endDate");
		String status = bk.get("status");
		String emergency = bk.get("emergency");
		String validateOn = bk.get("validateOn");
		String validateBy = bk.get("validateBy");
		String contactDetail = bk.get("contactDetail");
		String reason = bk.get("reason");
		
//		bookingId = extras.getString("bookingId");
//		facilityName = extras.getString("facilityName");
//		startDate = extras.getString("statyDate");
//		endDate = extras.getString("endDate");
//		status = extras.getString("status");
//		emergency = extras.getString("emergency");
//		validateOn = extras.getString("validateOn");
//		validateBy = extras.getString("validateBy");
//		contactDetail = extras.getString("contactDetail");
//		reason = extras.getString("reason");
		
		
		TextView tvBookingId = (TextView) findViewById(R.id.textViewId);
		TextView tvFacility = (TextView) findViewById(R.id.textViewFN);
		TextView tvStartDate = (TextView) findViewById(R.id.textViewSD);
		TextView tvEndDate = (TextView) findViewById(R.id.textViewED);
		TextView tvStatus = (TextView) findViewById(R.id.textViewStatus);
		TextView tvEmergency = (TextView) findViewById(R.id.textViewEmergency);
		TextView tvValidateOn = (TextView) findViewById(R.id.textViewVO);
		TextView tvValidateBy = (TextView) findViewById(R.id.textViewVB);
		TextView tvContactDetail = (TextView) findViewById(R.id.textViewCD);
		TextView tvReason = (TextView) findViewById(R.id.textViewReason);
		tvBookingId.setText(id);
		tvFacility.setText(facility);
		tvStartDate.setText(startDate);
		tvEndDate.setText(endDate);
		tvStatus.setText(status);
		tvEmergency.setText(emergency);
		tvValidateOn.setText(validateOn);
		tvValidateBy.setText(validateBy);
		tvContactDetail.setText(contactDetail);
		tvReason.setText(reason);
		//11
	
		Button button = (Button)findViewById(R.id.button1);
		check = intent.getExtras().getString("check");
		if(check.matches("status"))
		{
			button.setText("Delete");
			status = "Delete";
			back = BookingStatus.class;
		}
		else if(check.matches("history"))
		{
			button.setText("Cancel");
			status = "Cancel";
			back = BookingHistory.class;
		}
	
	}
	
	public void ChangeStatus()
	{
		ChangeBookingStatus.Update(id, status);
		Intent itn = new Intent(this,back);
		startActivity(itn);
	}
}
